找传奇、传世资源到传世资源站!

证件生成器(C# 搞笑)

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

证件生成器(C# 搞笑) C#语言基础-第1张using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Drawing.Drawing2D;using System.Drawing.Imaging;namespace 超级搞笑证件生成器{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } Graphics g=null ; private void Form1_Load(object sender, EventArgs e) { drawTime(); cboxType.SelectedIndex = 0; } private void drawTime() { drawString(DateTime.Now.ToShortDateString(), 350, 263); } private void btnChosePhote_Click(object sender, EventArgs e) { OpenFileDialog open = new OpenFileDialog(); if (open.ShowDialog() == DialogResult.OK) { txtPath.Text = open.FileName; switch (cboxType.Text.Trim()) { case "十二生肖": drawImage(0, txtPath.Text.Trim()); break; case "武林证件": drawImage(1, txtPath.Text.Trim()); break; case "男生证件": drawImage(2, txtPath.Text.Trim()); break; case "女生证件": drawImage(3, txtPath.Text.Trim()); break; case "爱情证件": drawImage(4, txtPath.Text.Trim()); break; case "学历证件": drawImage(5, txtPath.Text.Trim()); break; case "荣誉证书": drawImage(6, txtPath.Text.Trim()); break; case "社会证件": drawImage(7, txtPath.Text.Trim()); break; case "综合证件": drawImage(8, txtPath.Text.Trim()); break; } pbox.Refresh(); } } private void drawString(string str, int x, int y) { g = Graphics.FromImage(pbox.Image); g.DrawString(str, new Font("宋体", 15), Brushes.Blue , new Point(x, y)); pbox.Refresh(); g.Dispose(); } private void drawAge(int i, string age)//绘制年龄 { g = Graphics.FromImage(pbox.Image); if (i == 0)//如果是十二生肖证件 { drawString(txtAge.Text.Trim(), 330, 95); } else if (i == 1)//如果是武林证件 { drawString(txtAge.Text.Trim(), 410, 95); } else if (i == 2)//如果是男生证件 { drawString(txtAge.Text.Trim(), 310, 85); } else if (i == 3)//如果是女生证件 { drawString(txtAge.Text.Trim(), 310, 85); } else if (i == 4)//如果是爱情证件 { drawString(txtAge.Text.Trim(), 310, 85); } else if (i == 5)//如果是学历证件 { drawString(txtAge.Text.Trim(), 310, 70); } else if (i == 6)//如果是荣誉证书 { drawString(txtAge.Text.Trim(), 310, 80); } else if (i == 7)//如果是社会证件 { drawString(txtAge.Text.Trim(), 310, 80); } else if (i == 8)//如果是综合证件 { drawString(txtAge.Text.Trim(), 310, 80); } pbox.Refresh(); g.Dispose(); } private void drawSex(int i, string sex)//绘制性别 { g = Graphics.FromImage(pbox.Image); if (i == 0)//如果是十二生肖证件 { drawString(txtSex.Text.Trim(), 330, 65); } else if (i == 1)//如果是武林证件 { drawString(txtSex.Text.Trim(), 410, 65); } else if (i == 2)//如果是男生证件 { drawString(txtSex.Text.Trim(), 310, 65); } else if (i == 3)//如果是女生证件 { drawString(txtSex.Text.Trim(), 310, 65); } else if (i == 4)//如果是爱情证件 { drawString(txtSex.Text.Trim(), 310, 65); } else if (i == 5)//如果是学历证件 { drawString(txtSex.Text.Trim(), 310, 50); } else if (i == 6)//如果是荣誉证书 { drawString(txtSex.Text.Trim(), 310, 60); } else if (i == 7)//如果是社会证件 { drawString(txtSex.Text.Trim(), 310, 60); } else if (i == 8)//如果是综合证件 { drawString(txtSex.Text.Trim(), 310, 60); } pbox.Refresh(); g.Dispose(); } private void drawName(int i, string name)//绘制姓名 { g = Graphics.FromImage(pbox.Image); if (i == 0)//如果是十二生肖证件 { g.DrawString(name, new Font("宋体", 15), Brushes.Blue, new Point(330, 35)); } else if (i == 1)//如果是武林证件 { g.DrawString(name, new Font("宋体", 15), Brushes.Blue, new Point(410, 35)); } else if (i == 2)//如果是男生证件 { g.DrawString(name, new Font("宋体", 15), Brushes.Blue, new Point(310, 45)); } else if (i == 3)//如果是女生证件 { g.DrawString(name, new Font("宋体", 15), Brushes.Blue, new Point(310, 45)); } else if (i == 4)//如果是爱情证件 { g.DrawString(name, new Font("宋体", 15), Brushes.Blue, new Point(310, 45)); } else if (i == 5)//如果是学历证件 { g.DrawString(name, new Font("宋体", 15), Brushes.Blue, new Point(310, 35)); } else if (i == 6)//如果是荣誉证书 { g.DrawString(name, new Font("宋体", 15), Brushes.Blue, new Point(310, 40)); } else if (i == 7)//如果是社会证件 { g.DrawString(name, new Font("宋体", 15), Brushes.Blue, new Point(310, 40)); } else if (i == 8)//如果是综合证件 { g.DrawString(name, new Font("宋体", 15), Brushes.Blue, new Point(310, 40)); } pbox.Refresh(); g.Dispose(); } private void drawImage(int i,string imagePath) { g = Graphics.FromImage(pbox.Image); Image img = Image.FromFile(imagePath); if (i == 0)//如果是十二生肖证件 { g.DrawImage(img, 395, 30, 75, 85); } else if (i == 1)//如果是武林证件 { g.DrawImage(img, 280, 35, 80, 90); } else if (i == 2)//如果是男生证件 { g.DrawImage(img, 388, 35, 75, 85); } else if (i == 3)//如果是女生证件 { g.DrawImage(img, 388, 35, 75, 85); } else if (i == 4)//如果是爱情证件 { g.DrawImage(img, 388, 35, 75, 85); } else if (i == 5)//如果是学历证件 { g.DrawImage(img, 388, 35, 75, 85); } else if (i == 6)//如果是荣誉证书 { g.DrawImage(img, 388, 35, 75, 85); } else if (i == 7)//如果是社会证件 { g.DrawImage(img, 388, 35, 75, 85); } else if (i == 8)//如果是综合证件 { g.DrawImage(img, 388, 35, 75, 85); } pbox.Refresh(); g.Dispose(); img.Dispose(); } private void txtName_TextChanged(object sender, EventArgs e) { string name = txtName.Text.Trim(); switch (cboxType.Text.Trim()) { case "十二生肖": drawName(0, name); break; case "武林证件": drawName(1, name); break; case "男生证件": drawName(2, name); break; case "女生证件": drawName(3, name); break; case "爱情证件": drawName(4, name); break; case "学历证件": drawName(5, name); break; case "荣誉证书": drawName(6, name); break; case "社会证件": drawName(7, name); break; case "综合证件": drawName(8, name); break; } } private void btnOk_Click(object sender, EventArgs e) { SaveFileDialog save = new SaveFileDialog(); save.InitialDirectory = "C:\\Documents and Settings\\Administrator\\My Documents\\My Pictures"; save.Filter = "Bitmap Image|*.bmp"; save.Title = "保存图像"; save.ShowDialog(); if (save.FileName != "") { pbox.Image.Save(save.FileName, ImageFormat.Bmp); } } private void txtSex_TextChanged(object sender, EventArgs e) { string sex = txtSex.Text.Trim(); switch (cboxType.Text.Trim()) { case "十二生肖": drawSex(0, sex); break; case "武林证件": drawSex(1, sex); break; case "男生证件": drawSex(2, sex); break; case "女生证件": drawSex(3, sex); break; case "爱情证件": drawSex(4, sex); break; case "学历证件": drawSex(5, sex); break; case "荣誉证书": drawSex(6, sex); break; case "社会证件": drawSex(7, sex); break; case "综合证件": drawSex(8, sex); break; } } private void txtAge_TextChanged(object sender, EventArgs e) { string age = txtAge.Text.Trim(); switch (cboxType.Text.Trim()) { case "十二生肖": drawAge(0, age); break; case "武林证件": drawAge(1, age); break; case "男生证件": drawAge(2, age); break; case "女生证件": drawAge(3, age); break; case "爱情证件": drawAge(4, age); break; case "学历证件": drawAge(5, age); break; case "荣誉证书": drawAge(6, age); break; case "社会证件": drawAge(7, age); break; case "综合证件": drawAge(8, age); break; } } private void cboxType_SelectedIndexChanged(object sender, EventArgs e) { switch (cboxType.Text.Trim())//根据证件类型切换对应模板 { case "十二生肖": addItem(0); break; case "武林证件": addItem(1); break; case "男生证件": addItem(2); break; case "女生证件": addItem(3); break; case "爱情证件": addItem(4); break; case "学历证件": addItem(5); break; case "荣誉证书": addItem(6); break; case "社会证件": addItem(7); break; case "综合证件": addItem(8); break; } if (cboxMode.Items.Count > 0)//选中第一项 { cboxMode.SelectedIndex = 0; } } private void addItem(int i)//根据传过来的类型值动态改变模板的值 { int j = 0; cboxMode.Items.Clear();//清空原有的值 string[] s1={"鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"}; string[] s2 ={ "峨嵋派", "丐帮", "全真教", "日月神教", "少林派", "武当派"}; string[] s3 ={ "处男证", "光棍证", "好男人证", "超级帅哥证", "好老公证", "泡妞证", "嫖娼许可证", "色狼证", "少女杀手证" }; string[] s4 ={ "处女证", "良家妇女证", "乖乖女证", "超级美眉证", "淑女证", "超级猛女证", "好老婆证", "恐龙证"}; string[] s5 ={ "痴情证", "失恋证", "网恋许可证", "征婚证" }; string[] s6 ={ "吹牛博士证", "哈佛MBA证", "爱情博士证", "牛津BT教授证", "清华YY博士证", "游戏博士证"}; string[] s7 ={ "麦霸证", "魔法师证","上Q先进证", "QQ空间明星证", "奥斯卡影帝证" }; string[] s8 ={ "扁人许可证", "吹牛许可证", "赌神证", "职业聊天证", "律师执业证", "杀手证", "通缉令证", "土匪资格证", "屠夫证", "行乞证", "心理咨询师证" }; string[] s9 ={ "死不要脸证", "灌水证", "良好市民证", "忽悠证", "浆糊证", "潜水证", "世界首富证", "天才证"}; switch (i)//根据传过来的类型值动态改变模板的值 { case 0: for (j=0; j < s1.Length; j ) { cboxMode.Items.Add(s1[j]); } break; case 1: for (j=0; j < s2.Length; j ) { cboxMode.Items.Add(s2[j]); } break; case 2: for (j = 0; j < s3.Length; j ) { cboxMode.Items.Add(s3[j]); } break; case 3: for (j = 0; j < s4.Length; j ) { cboxMode.Items.Add(s4[j]); } break; case 4: for (j = 0; j < s5.Length; j ) { cboxMode.Items.Add(s5[j]); } break; case 5: for (j = 0; j < s6.Length; j ) { cboxMode.Items.Add(s6[j]); } break; case 6: for (j = 0; j < s7.Length; j ) { cboxMode.Items.Add(s7[j]); } break; case 7: for (j = 0; j < s8.Length; j ) { cboxMode.Items.Add(s8[j]); } break; case 8: for (j = 0; j < s9.Length; j ) { cboxMode.Items.Add(s9[j]); } break; } } private void cboxMode_SelectedIndexChanged(object sender, EventArgs e)//根据对应模板的值切换证件图片 { switch (cboxMode.Text.Trim()) { case "鼠": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.sxshu; break; case "牛": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.sxniu; break; case "虎": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.sxhu; break; case "兔": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.sxtu; break; case "龙": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.sxlong; break; case "蛇": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.sxshe; break; case "马": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.sxma; break; case "羊": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.sxyang; break; case "猴": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.sxhou; break; case "鸡": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.sxji; break; case "狗": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.sxgou; break; case "猪": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.sxzhu; break; case "峨嵋派": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.wlemei; break; case "丐帮": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.wlgaibang; break; case "全真教": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.wlquanzhen; break; case "日月神教": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.wlriyue; break; case "少林派": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.wlshaolin; break; case "武当派": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.wlwudang; break; case "处男证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.chunan; break; case "光棍证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.guanggun; break; case "好男人证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.haonanren; break; case "超级帅哥证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.shuaige; break; case "好老公证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.laogong; break; case "泡妞证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.paoniu; break; case "嫖娼许可证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.piaochang; break; case "色狼证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.selang; break; case "少女杀手证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.shaonv; break; case "处女证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.chunv; break; case "良家妇女证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.funv; break; case "乖乖女证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.guaiguai; break; case "超级美眉证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.mm; break; case "淑女证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.shunv; break; case "超级猛女证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.mengnv; break; case "好老婆证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.laopo; break; case "恐龙证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.konglong; break; case "痴情证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.chiqing; break; case "失恋证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.shilian ; break; case "网恋许可证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.wanglian ; break; case "征婚证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.zhenghun ; break; case "吹牛博士证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.cuiniuboshi; break; case "哈佛MBA证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.hafouMBA ; break; case "爱情博士证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.jianqiao ; break; case "牛津BT教授证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.niujin ; break; case "清华YY博士证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.qinghuaYY ; break; case "游戏博士证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.yelu; break; case "麦霸证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.maiba ; break; case "魔法师证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.mofashi ; break; case "上Q先进证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.qqxianjin; break; case "QQ空间明星证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.qzone; break; case "奥斯卡影帝证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.yingdi ; break; case "扁人许可证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.bianren ; break; case "吹牛许可证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.cuiniu ; break; case "赌神证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.dushen ; break; case "职业聊天证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.liaotian ; break; case "律师执业证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.lvshi ; break; case "杀手证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.shashou ; break; case "通缉令证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.tongjiling ; break; case "土匪资格证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.tufei ; break; case "屠夫证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.tufu ; break; case "行乞证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.xingqi ; break; case "心理咨询师证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.xinli; break; case "死不要脸证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.buyaolian ; break; case "灌水证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.guanshui ; break; case "良好市民证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.haoshimin; break; case "忽悠证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.huyou ; break; case "浆糊证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.jianghu ; break; case "潜水证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.qianshui ; break; case "世界首富证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.shoufu ; break; case "天才证": pbox.Image = global::超级搞笑证件生成器.Properties.Resources.tiancai ; break; } txtName_TextChanged(null ,null ); txtSex_TextChanged(null, null); txtAge_TextChanged(null, null); drawTime();//重画日期时间 pbox.Refresh();//刷新图片框 } private void btnExit_Click(object sender, EventArgs e) { MessageBox.Show("作者:刘典武 (游龙工作室)" "\r\n" "网址:http://www.liudianwu1988.51.com", "呵呵", MessageBoxButtons.OK, MessageBoxIcon.Information); Application.ExitThread(); } }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复